﻿<div class="modal fade" id="PlatformSwitchModal" tabindex="-1" role="dialog" aria-labelledby="PlatformSwitchModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="margin-top:20%;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="PlatformSwitchModalLabel">
                    切换应用
                </h4>
            </div>
            <div id="PlatformSwitchmodalBody" class="modal-body" style="padding-top:30px;padding-bottom:30px;">
                <ul class="clearfix">
                    @{
                        foreach(Application item in Model) {
                            <li style="background-color:@RandomHelper.GetRandomColor()"><i>@item.ID</i><span>@item.Name</span></li>
                        }
                    }
                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="PlatformSwitch()">
                    提交更改
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    var platform;
    $(function () {
        $("#PlatformSwitchmodalBody ul li").each(function () {
            $("#PlatformSwitchmodalBody ul li").click(function () {
                $("#PlatformSwitchmodalBody ul li").css("border", "1px solid #999");
                $(this).css("border", "2px solid #444");

                platform = $(this).children("i").text();

                localStorage.setItem("current_system", platform);
                $.cookie('current_system', platform, { expires: 7, path: '/' });
                parent.document.body.currentsystem = platform;
                document.body.currentsystem = platform;
          
            })
        });
    });
    function PlatformSwitch() {
        if (!!platform) {
            $.deleteForm({
                prompt: "注：您确定要切换系统吗？",
                loading: "正在切换系统...",
                url: "/Home/PlatformSwitch",
                param: { keyValue: platform },
                success: function () {
                    layer.msg('切换系统成功');
                    refreshView();
                }
            })
        } else {
            layer.msg('请选择系统');
        }
     
    }
</script>